/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.lacibMusic.conversores;

/**
 *
 * @author AlanmLira
 */


import br.com.lacibMusic.entidades.Compositor;
import br.com.lacibMusic.rn.CompositorRN;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;


@FacesConverter(forClass = Compositor.class)
public class CompositorConversor implements Converter{
    private final CompositorRN compositorRN = new CompositorRN();

    @Override
    public Object getAsObject(FacesContext fc, UIComponent uic, String valor) {
        return compositorRN.obter(new Integer(valor));
    }

    @Override
    public String getAsString(FacesContext fc, UIComponent uic, Object o) {
        Compositor compositor = (Compositor) o;
        return compositor.getId().toString();
    }
}
